Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for dumping variables using 'printf' for testing scenarios where std is not avalible. #3

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

FractalFir
Copy link

I was interested in using this project to detect bugs in my experimental codegen backend. I don't have support for Rust formatting yet, so I tried to get rustlantis to work without using the standard Rust lib.

This pull request adds the ability to dump variables using printf instead of the standard Rust formatter, when the --printf_debug option is specified.

@FractalFir
Copy link
Author

A question: Is there an upper bound on tuple element count? If so, what is it?

@cbeuw
Copy link
Owner

cbeuw commented Jan 31, 2024

Have to say I'm flattered that my code is readable enough for someone else to work on it 😛

A question: Is there an upper bound on tuple element count? If so, what is it?

12: https://doc.rust-lang.org/std/primitive.tuple.html#trait-implementations-1

Comment on lines 29 to +30
arg!(-d --debug "generate a program where values are printed instead of hashed (slow)"),
arg!(-p --printf_debug "generate a program where values are printed using the C 'printf' function instead of hashed (slow)"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI stability is not a concern. So you could replace -d with a single enum flag with 3 options, defaulting to HashDumper

fn printf(fmt: *const c_char, ...) -> c_int;
}
trait PrintFDebug{
fn printf_debug(&self);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it unsafe fn here and in the implementations instead of using unsafe blocks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants